# _*_ coding: utf-8 _*_
# @Time : 2024-01-18 22:26
# @Author : wf

import lxml.etree as etree
import urllib.request as request
import http.client

url = 'https://www.baidu.com'
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'}

req = request.Request(url, headers=headers)

response: http.client.HTTPResponse = request.urlopen(req)
content = response.read().decode('utf-8')

# print(content)
# 解析网页源码
html_tree: etree._ElementTree = etree.HTML(content)
res_list = html_tree.xpath('//input[@id="su"]/@value')
print(res_list)
print(res_list[0])
